package file;

import java.io.File;
import java.io.FileFilter;

public class ListFileDemo2 {
    public static void main(String[] args) {

        File file=new File(".");


        if(file.isDirectory()){
            File[] files=file.listFiles(new FileFilter() {
                @Override
                public boolean accept(File pathname) {
                 String name=pathname.getName();
                    return name.endsWith(".txt");
                }
            });
            for(File sub:files){
                System.out.println(sub.getName());
            }
        }


    }
}
